package com.mojo.redisson.observerPattern;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 报名主题
 *
 * @author <a href="mailto:mojo_jj@163.com">Mojo</a>
 */
@Component
public class ApplySubject {
    List<ApplyObserver> observers = new ArrayList<>();

    public void notifyObservers(String message) {
        for (ApplyObserver observer : observers) {
            observer.afterApply(message);
        }
    }

    public void addObserver(ApplyObserver observer) {
        observers.add(observer);
    }

    public void removeObserver(ApplyObserver observer) {
        observers.remove(observer);
    }
}
